angular.module('faApp')
  .service('productService', [ 'ajaxService',function (ajaxService) {

    this.productList = function (cfg) {
      return ajaxService.post(ajaxService.getApiUri("PRODUCT_LIST"),cfg || {});
    };  

    //查询产品公告列表
    this.queryProductNoticeList = function (cfg) {
      return ajaxService.jsonp(ajaxService.getApiUri("QUERY_PRODUCT_NOTICE_LIST"),cfg || {});
    }; 
     //查询产品公告详情
    this.queryProductNoticeDetail = function (cfg) {
      return ajaxService.jsonp(ajaxService.getApiUri("QUERY_PRODUCT_NOTICE_DETAIL"),cfg || {});
    }; 
    //编辑产品公告
    this.editProductNotice = function (cfg) {
      return ajaxService.post(ajaxService.getApiUri("EDIT_PRODUCT_NOTICE"),cfg || {});
    }; 

    //查询pe/vc 产品列表
    this.queryProductList = function (cfg) {
      return ajaxService.post(ajaxService.getApiUri("QUERY_PRODUCT_LIST"),cfg || {});
    }; 
    //查询pe/vc 产品新增
    this.productAddPEVC = function (product,cfg) {
      return ajaxService.post(ajaxService.getApiUri("ADD_PRODUCT_DETAIL"),product || {});
    }; 

    //查询pe/vc 产品编辑
    this.productUpdatePEVC = function (product,cfg) {
      return ajaxService.post(ajaxService.getApiUri("UPDATE_PRODUCT_DETAIL"),product || {});
    }; 
    this.productAdd = function (product,ct) {
      return ajaxService.post(ajaxService.getApiUri("PRODUCT_ADD"), product || {});
    };  

    this.productEdit = function (product) {
      return ajaxService.post(ajaxService.getApiUri("PRODUCT_EDIT"),product || {});
    };  

    this.productQuery = function (id) {
      return ajaxService.post(ajaxService.getApiUri("PRODUCT_QUERY"),{id:id});
    };  

    //渠道查询产品详情
    this.productQdQuery =function (id){
       return ajaxService.post(ajaxService.getApiUri("QD_PRODUCT_QUERY"),{pId:id});
    }

    //产品成立
    this.productEstablish = function (cfg) {
      return ajaxService.post(ajaxService.getApiUri("PRODUCT_SET"),cfg || {});
    };  

    //下架3  上架2
    this.productStop = function (id,status) {
      return ajaxService.jsonp(ajaxService.getApiUri("PRODUCT_PUBLISH"),{id:id,pPublicStatus:status});
    };

    //发布
    this.productPassPublish = function (id) {
      return ajaxService.jsonp(ajaxService.getApiUri("PRODUCT_PUBLISH"),{id:id,status:3,pPublicStatus:2, isFabu: 'true'});
    };

    //审核通过
    this.productPassVerify = function (id) {
      return ajaxService.jsonp(ajaxService.getApiUri("PRODUCT_VERIFY"),{id:id,status:2,pPublicStatus:1});
    };

    //审核拒绝
    this.productDenyVerify = function (id,type) {

     var checkFailReason=prompt("请输入审批备注(可不填)");
        //审核不通过1;拒绝发布2
      if(type == 1){
          return ajaxService.jsonp(ajaxService.getApiUri("PRODUCT_VERIFY"),{id:id,status:1,pPublicStatus:4,checkFirstFailReason:checkFailReason});
      }else if(type == 2){
          return ajaxService.jsonp(ajaxService.getApiUri("PRODUCT_VERIFY"),{id:id,status:1,pPublicStatus:4,checkFailReason:checkFailReason});
      }

    }; 

    this.updateSaleProcess = function (product) {
      return ajaxService.post(ajaxService.getApiUri("PRODUCT_UPDATE_SALEPROCESS"),product || {});
    };  

    this.updateRecruitmentProcess = function (product) {
      return ajaxService.post(ajaxService.getApiUri("PRODUCT_UPDATE_Recruitment"),product || {});
    };  

    this.productRecommend = function (product) {
      return ajaxService.post(ajaxService.getApiUri("PRODUCT_RECOMMEND"),product || {});
    };    

    this.productDelete = function (id) {
      return ajaxService.jsonp(ajaxService.getApiUri("PRODUCT_DELETE"),{id:id});
    }; 

    this.productProfitList = function (id) {
      return ajaxService.post(ajaxService.getApiUri("PRODUCT_PROFIT_LIST"),{id:id});
    }; 

    this.productProfitLogList = function (id) {
      return ajaxService.post(ajaxService.getApiUri("PRODUCT_PROFIT_LOG_LIST"),{pId:id});
    }; 

    this.productProfitUpdate = function (data) {
      return ajaxService.post(ajaxService.getApiUri("PRODUCT_PROFIT_UPDATE"),data || {});
    }; 

    this.productAttachList = function (id) {
      return ajaxService.jsonp(ajaxService.getApiUri("PRODUCT_ATTACH_LIST"),{pId:id});
    }; 

    this.productAttachUpdate = function (data) {
      return ajaxService.post(ajaxService.getApiUri("PRODUCT_ATTACH_UPDATE"),data || {});
    }; 
    
    this.transPermissionAdd = function(data){
      return ajaxService.post(ajaxService.getApiUri("PRODUCT_TRANS_ADD"),data || {});
    }
    
    this.transPermissionList = function(data){
      return ajaxService.post(ajaxService.getApiUri("PRODUCT_TRANS_LIST"),data || {});
    }

    this.sendEmail = function(ids){
      return ajaxService.post(ajaxService.getApiUri("PRODUCT_SEND_EMAIL") , {id:ids})
    }

     this.productQDList = function (cfg) {
      return ajaxService.post(ajaxService.getApiUri("PRODUCT_QUDAO_LIST"),cfg || {});
    }; 

    this.addProductCheckVerify = function (cfg) {
      return ajaxService.post(ajaxService.getApiUri("PRODUCT_ADD_CHECK"),cfg || {});
    };

      this.productNoticeQuery = function (cfg) {
          return ajaxService.post(ajaxService.getApiUri("PRODUCT_NOTICE_QUERY"),cfg || {});
      };
      this.productNoticeDelete = function (cfg) {
          return ajaxService.post(ajaxService.getApiUri("PRODUCT_NOTICE_DELETE"),cfg || {});
      };
      this.proSeriesAdd = function (cfg) {
          return ajaxService.post(ajaxService.getApiUri("PRODUCT_SERIES_ADD"),cfg || {});
      };
     this.proSeriesList = function (cfg) {
          return ajaxService.post(ajaxService.getApiUri("PRODUCT_SERIES_LIST"),cfg || {});
      };
      this.proSeriesDelete = function (cfg) {
          return ajaxService.post(ajaxService.getApiUri("PRODUCT_SERIES_DELETE"),cfg || {});
      };
      this.xcxSearchNoRecordList = function (cfg) {
          return ajaxService.post(ajaxService.getApiUri("PRODUCT_SEARCHNO_RECORD_LIST"),cfg || {});
      };

      this.queryAllProductByFullName = function (cfg) {
          return ajaxService.post(ajaxService.getApiUri("QUERY_ALL_PRODUCT_BY_FULLNAME"),cfg || {});
      };
  }]);
 



